This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library("hdxstats")
library("dplyr")
library("ggplot2")
library("RColorBrewer")
library("tidyr")
library("pheatmap")
library("scales")
library("viridis")
library("patchwork")
library("Biostrings")
library("xfun")
#data_filepath <- "vignettes/data/MBPqDF_test.rsd"
#hdx_data <- extract_hdx_data(data_filepath) # DONE
# TEST 1
# INPUT
data_selection <- hdx_data[,1:24]
all_peptides <- rownames(data_selection)[[1]]
starting_parameters <- list(a = NULL, b = 0.001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "fit",
peptide_selection = all_peptides,
start = starting_parameters)
[1] "INFO: Performing fitting of Deuterium uptake kinetics. Method: 'hdxstats::fitUptakeKinetics' "
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "Could not fit model, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "Could not fit model, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
results$method
[1] "fitUptakeKinetics"
graphics_kinetic <- visualise_hdx_data(results, type="kinetics")
[1] "INFO: I found 104 models in your results data."
graphics_kinetic[[1]] | graphics_kinetic[[2]] | graphics_kinetic[[3]]
graphics <- visualise_hdx_data(results, type="forest")
[1] "INFO: I found 104 models in your results data."
graphics[[1]] | graphics_kinetic[[1]]
graphics[[1]]$data
data_selection <- hdx_data[,1:100]
all_peptides <- rownames(data_selection)[[1]] # get all peptides
starting_parameters <- list(a = NULL, b = 0.0001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "dfit",
peptide_selection = all_peptides[37],
start = starting_parameters)
[1] "INFO: Performing differential fitting of Deuterium uptake kinetics. Method: 'hdxstats::differentialUptakeKinetics' "
[1] "INFO: You did not specify a 'formula' for your fitting model."
[1] "INFO: Fitting will be performed for (default): 'formula <- value ~ a * (1 - exp(-b*(timepoint)^p)) + d' "
graphics <- visualise_hdx_data(results, type="kinetics")
[1] "INFO: I found 7 models in your results data."
graphics
head(HOIP)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'head': object 'HOIP' not found
EXAMPLE: Tutorial 1
csv_filename <- "MBP.csv"
csv_filepath <- system.file("extdata", csv_filename, package = "hdxstats")
data <- read.csv(csv_filepath)
columns_names <- c("hx_time", "replicate_cnt", "hx_sample") # to merge into new column names
columns_fixed <- c("pep_sequence", "pep_charge")
# transform data
data_wide <- pivot_wider(data.frame(data),
values_from = d, # Deu_Uptake
names_from = columns_names, # Exposure_Time, Replicate, Other
id_cols = columns_fixed) # Sequence, Charge
Error in pivot_wider(data.frame(data), values_from = d, names_from = columns_names, :
could not find function "pivot_wider"
EXAMPLE: Tutorial 3 (HOIP)
HOIPpath <- system.file("extdata", "N64184_1a2_state.csv", package = "hdxstats")
HOIP <- read.csv(HOIPpath)
HOIP_wide <- pivot_wider(data.frame(HOIP),
values_from = Center, # Deu_Uptake
names_from = c("Exposure", "State"), # Exposure_Time, Replicate (NA), Conditions, Other
id_cols = c("Sequence")) # Sequence, Charge (NA)
EXAMPLE: Case study
secA <- read.csv("inst/extdata/Project_2_SecA_Cluster_Data.csv")
secA_wide <- pivot_wider(data.frame(secA),
values_from = "Center", # Deu_Uptake
names_from = c("Exposure", "File", "State"), # Exposure_Time, Replicate, Conditions, Other (NA or "")
id_cols = c("Sequence", "z")) # Sequence, Charge
graphics <- visualise_hdx_data(results, type="kinetics") # READY
graphics <- visualise_hdx_data(results, type="forest") # READY
graphics <- visualise_hdx_data(results, type="manhatten")# <<<<--- NEXT
graphics <- visualise_hdx_data(results, type="peptide")
graphics <- visualise_hdx_data(results, type="epitope", level="peptide")
graphics <- visualise_hdx_data(results, type="epitope", level="residue") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="peptide") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="residue") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="residue", pdb="my_pdb_path")
########################################################################
# TUTORIAL 1 & 2
#data_filepath <- "/homes/sanjuan/R/x86_64-pc-linux-gnu-library/4.1/hdxstats/extdata/MBP.csv"
#data_filepath <- system.file("extdata", csv_filename, package = "hdxstats")
#data_filepath <- "vignettes/data/MBPqDF.rsd" # or, CSV file
# TUTORIAL 3 & 4 (HOIP assays)
#data_filepath <- system.file("extdata", "N64184_1a2_state.csv", package = "hdxstats")
# TUTORIAL secA-casestudy
#data_path <- "inst/extdata/Project_2_SecA_Cluster_Data.csv"
# TUTORIAL flexible-fits.Rmd
#MBPpath <- system.file("extdata", "MBP.csv", package = "hdxstats")
#######################################################
data_filepath <- "vignettes/data/MBPqDF.rsd"
hdx_data <- extract_hdx_data(data_filepath) # DONE
# TEST 1
# INPUT
data_selection <- hdx_data[,1:24]
all_peptides <- rownames(data_selection)[[1]]
starting_parameters <- list(a = NULL, b = 0.001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "fit",
peptide_selection = all_peptides,
start = starting_parameters)
# TEST 2
# INPUT
data_selection <- hdx_data[,61:100]
all_peptides <- rownames(data_selection)[[1]]
starting_parameters <- list(a = NULL, b = 0.001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "fit",
peptide_selection = all_peptides,
start = starting_parameters)
# TEST 3
# INPUT
data_selection <- hdx_data[,1:100]
all_peptides <- rownames(data_selection)[[1]] # get all peptides
starting_parameters <- list(a = NULL, b = 0.0001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "dfit",
peptide_selection = all_peptides[37],
start = starting_parameters)
#######################################################
graphics <- visualise_hdx_data(results, type="kinetics") # This applies to both regular and differential fits
graphics <- visualise_hdx_data(results, type="forest") # This only applies to regular fits
graphics <- visualise_hdx_data(results, type="manhatten") # This only applies to differential fits
graphics <- visualise_hdx_data(results, type="epitope", level="peptide")
graphics <- visualise_hdx_data(results, type="epitope", level="residue") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="peptide") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="residue") # Return heatmap
graphics <- visualise_hdx_data(results, type="protection", level="residue", pdb="my_pdb_path")
# GUI: Make GUI by assembling these building blocks